package com.leon.agent.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.leon.agent.common.annotation.Log;
import com.leon.agent.common.enums.BusinessType;
import com.leon.agent.biz.domain.BizPlatform;
import com.leon.agent.biz.service.IBizPlatformService;
import com.leon.agent.common.core.controller.BaseController;
import com.leon.agent.common.core.domain.AjaxResult;
import com.leon.agent.common.utils.poi.ExcelUtil;
import com.leon.agent.common.core.page.TableDataInfo;

/**
 * 第三方平台Controller
 * 
 * @author leon_agent
 * @date 2025-05-23
 */
@Controller
@RequestMapping("/biz/platform")
public class BizPlatformController extends BaseController
{
    private String prefix = "biz/platform";

    @Autowired
    private IBizPlatformService bizPlatformService;

    @RequiresPermissions("biz:platform:view")
    @GetMapping()
    public String platform()
    {
        return prefix + "/platform";
    }

    /**
     * 查询第三方平台列表
     */
    @RequiresPermissions("biz:platform:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizPlatform bizPlatform)
    {
        startPage();
        List<BizPlatform> list = bizPlatformService.selectBizPlatformList(bizPlatform);
        return getDataTable(list);
    }

    /**
     * 导出第三方平台列表
     */
    @RequiresPermissions("biz:platform:export")
    @Log(title = "第三方平台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizPlatform bizPlatform)
    {
        List<BizPlatform> list = bizPlatformService.selectBizPlatformList(bizPlatform);
        ExcelUtil<BizPlatform> util = new ExcelUtil<BizPlatform>(BizPlatform.class);
        return util.exportExcel(list, "第三方平台数据");
    }

    /**
     * 新增第三方平台
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存第三方平台
     */
    @RequiresPermissions("biz:platform:add")
    @Log(title = "第三方平台", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizPlatform bizPlatform)
    {
        return toAjax(bizPlatformService.insertBizPlatform(bizPlatform));
    }

    /**
     * 修改第三方平台
     */
    @RequiresPermissions("biz:platform:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BizPlatform bizPlatform = bizPlatformService.selectBizPlatformById(id);
        mmap.put("bizPlatform", bizPlatform);
        return prefix + "/edit";
    }

    /**
     * 修改保存第三方平台
     */
    @RequiresPermissions("biz:platform:edit")
    @Log(title = "第三方平台", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizPlatform bizPlatform)
    {
        return toAjax(bizPlatformService.updateBizPlatform(bizPlatform));
    }

    /**
     * 删除第三方平台
     */
    @RequiresPermissions("biz:platform:remove")
    @Log(title = "第三方平台", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizPlatformService.deleteBizPlatformByIds(ids));
    }
}
